#include <stdio.h>
#include <time.h>
#include <stdlib.h>


int main(int argc, char **argv)
{
	srand((int)time(0));   //设置时间种子

	int num = rand()%100000;   //生成100000内的随机数
	printf("rand num:%6d\n", num);
	
	struct tm *p;
	time_t second;
	time(&second);

	p = localtime(&second);	//获取当前时间

	char buf[100] = {0};

	sprintf(buf, "%d-%d-%d %d:%d:%d_%06d", 1900+p->tm_year, 1+p->tm_mon, p->tm_mday,
			p->tm_hour, p->tm_min, p->tm_sec, num);  //格式化时间和随机数字符串，存放在buf内

	printf("guid:%s\n", buf);  //输出guid到控制台

	return 0;
}
